﻿@page "/"
@using HdhNetQuery
@using System.Data
@using HdhBlazor.HdhBll
@using System.Text.Json;

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>
&nbsp;&nbsp;&nbsp;<a onclick="ListStatus(1)">展示</a>
&nbsp;&nbsp;&nbsp;<a onclick="ListStatus(0)">隐藏</a>
<b>@ReturnResut</b>
<table class="table" id="table">
    <thead>
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>入学日期</th>
        </tr>
    </thead>
    <tbody>
        @foreach (DataRow dataRow in hm.GetStuInfo().Rows)
        {
            <tr>
                <td>@dataRow["Id"]</td>
                <td>@dataRow["Name"]</td>
                <td>@dataRow["AdmissionDate"]</td>
            </tr>
        }
    </tbody>
</table>
<script>
    function ListStatus(a){
        switch(a){
            case 1:
              document.getElementById("table").style.display="block";
              break;
            default:
              document.getElementById("table").style.display="none";
              break;
        }
    }
</script>
@code {
    HomeManager hm = new HomeManager();
    private string ReturnResut = "";
    protected override void OnInitialized()
    {
        HdhcmsDataHelperObject hdhcmsHelper = new HdhcmsDataHelperObject();
        // HdhcmsSQLiteHelper hdhcmsSQ = new HdhcmsSQLiteHelper();
        // string Sqlite = hdhcmsSQ.strConn;
        HdhcmsDataHelperStatic.GetConnString();
        string b =JsonSerializer.Serialize(new HdhcmsResultEntity());
        HdhcmsResultEntity a = HdhcmsGenericEntity.JsonStringToEntity<HdhcmsResultEntity>(b);
        if (a == null)
        {
            ReturnResut = "<b>对象为空</b>";
        }
        else
        {
            ReturnResut = $"Code:{a.Code};Success:{a.Success}";
        }
    }
}
